package javaJob.exercise.primary.string;

public class primary12_up {
    public static void main(String[] args) {
        int x = -120;
        int xx=1534236469;
        int xxx=-2143947412;
        System.out.println(reverse(xxx));
    }

    static int reverse(int x) {
        int res = 0;
        while (x != 0) {
            int t = x % 10;

            System.out.println("--"+t);

            int newRes = res * 10 + t;

            System.out.println("--"+newRes);

            //如果数字溢出，直接返回0
            if ((newRes - t) / 10 != res){
                System.out.println("::"+(newRes-t)/10);
                System.out.println("::::"+res);
                return 0;
            }
            res = newRes;
            x = x / 10;

            System.out.println("x:"+x);

        }
        return res;
    }
}
